package com.qf.shopping.controll;

import com.qf.shopping.pojo.System.Role;
import com.qf.shopping.pojo.member.Member;
import com.qf.shopping.service.SystemService;
import com.qf.shopping.vo.MenuVO;
import com.qf.shopping.vo.RolelistVO;
import com.qf.shopping.vo.RolesVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/role")
public class Rolescontroll {

    @Autowired
    private SystemService systemService=null;

    @GetMapping("/roles")
    public String getRoles(Model model){
        List<RolelistVO>list=systemService.getRoleList();
        model.addAttribute("roles",list);
        return "/roles/list";
    }

    @GetMapping("/addmenu")
    public String getMenu(Model model){
        return "/roles/add";
    }

    @PostMapping("/addmenu")
    public String getRoles(MenuVO menuVO){

        return "redirect:/role/roles";
    }

    @GetMapping("/updatemenu/{id}")
    public String toupdate(@PathVariable ("id") Integer id,Model model ){
        MenuVO menuVO=new MenuVO();
        menuVO.setMemberManage("on");
        menuVO.setArticle("on");
        model.addAttribute("menu",menuVO);
        return "/roles/update";
    }

    @PostMapping("/updatemenu")
    public String update(){

        return "redirect:/role/roles";
    }
    @GetMapping("/deletemenu/{id}")
    public String deletemenu(@PathVariable("id")Integer id){

        return "redirect:/role/roles";
    }
}
